import axios from 'axios'
import { Toast } from 'vant'
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'

axios.defaults.baseURL = 'https://elm.cangdu.org'
axios.interceptors.request.use(function (config) {
  NProgress.start()
  return config
}, function (error) {
  return Promise.reject(error)
})
// Add a response interceptor
axios.interceptors.response.use(function (response) {
  NProgress.done()
  return response
}, function (error) {
  Toast('错误: ' + error)
  return Promise.reject(error)
})

export default axios
